home *** CD-ROM | disk | FTP | other *** search
/ Champak 147 / (Vol 147) Jan 21 2012.iso / Interface / it.dig / scripts / __Packages / mx / controls / TextInput.as < prev    next >
Text File  |  2012-01-21  |  7KB  |  298 lines

  1. class mx.controls.TextInput extends mx.core.UIComponent
  2. {
  3.    static var symbolName = "TextInput";
  4.    static var symbolOwner = mx.controls.TextInput;
  5.    static var version = "2.0.2.127";
  6.    var className = "TextInput";
  7.    var initializing = true;
  8.    var clipParameters = {text:1,editable:1,password:1,maxChars:1,restrict:1};
  9.    static var mergedClipParameters = mx.core.UIObject.mergeClipParameters(mx.controls.TextInput.prototype.clipParameters,mx.core.UIComponent.prototype.clipParameters);
  10.    var _maxWidth = mx.core.UIComponent.kStretch;
  11.    var __editable = true;
  12.    var initText = "";
  13.    function TextInput()
  14.    {
  15.       super();
  16.    }
  17.    function addEventListener(event, handler)
  18.    {
  19.       if(event == "enter")
  20.       {
  21.          this.addEnterEvents();
  22.       }
  23.       super.addEventListener(event,handler);
  24.    }
  25.    function enterOnKeyDown()
  26.    {
  27.       if(Key.getAscii() == 13)
  28.       {
  29.          this.owner.dispatchEvent({type:"enter"});
  30.       }
  31.    }
  32.    function addEnterEvents()
  33.    {
  34.       if(this.enterListener == undefined)
  35.       {
  36.          this.enterListener = new Object();
  37.          this.enterListener.owner = this;
  38.          this.enterListener.onKeyDown = this.enterOnKeyDown;
  39.       }
  40.    }
  41.    function init(Void)
  42.    {
  43.       super.init();
  44.       this.label.styleName = this;
  45.       this.tabChildren = true;
  46.       this.tabEnabled = false;
  47.       this.focusTextField = this.label;
  48.       this._color = mx.core.UIObject.textColorList;
  49.       this.label.onSetFocus = function()
  50.       {
  51.          this._parent.onSetFocus();
  52.       };
  53.       this.label.onKillFocus = function(n)
  54.       {
  55.          this._parent.onKillFocus(n);
  56.       };
  57.       this.label.drawFocus = function(b)
  58.       {
  59.          this._parent.drawFocus(b);
  60.       };
  61.       this.label.onChanged = this.onLabelChanged;
  62.    }
  63.    function setFocus()
  64.    {
  65.       Selection.setFocus(this.label);
  66.    }
  67.    function onLabelChanged(Void)
  68.    {
  69.       this._parent.dispatchEvent({type:"change"});
  70.       this._parent.dispatchValueChangedEvent(this.__get__text());
  71.    }
  72.    function createChildren(Void)
  73.    {
  74.       super.createChildren();
  75.       if(this.border_mc == undefined)
  76.       {
  77.          this.createClassObject(_global.styles.rectBorderClass,"border_mc",0,{styleName:this});
  78.       }
  79.       this.border_mc.swapDepths(this.label);
  80.       this.label.autoSize = "none";
  81.    }
  82.    function get html()
  83.    {
  84.       return this.getHtml();
  85.    }
  86.    function set html(value)
  87.    {
  88.       this.setHtml(value);
  89.    }
  90.    function getHtml()
  91.    {
  92.       return this.label.html;
  93.    }
  94.    function setHtml(value)
  95.    {
  96.       if(value != this.label.html)
  97.       {
  98.          this.label.html = value;
  99.       }
  100.    }
  101.    function get text()
  102.    {
  103.       return this.getText();
  104.    }
  105.    function set text(t)
  106.    {
  107.       this.setText(t);
  108.    }
  109.    function getText()
  110.    {
  111.       if(this.initializing)
  112.       {
  113.          return this.initText;
  114.       }
  115.       if(this.label.html == true)
  116.       {
  117.          return this.label.htmlText;
  118.       }
  119.       return this.label.text;
  120.    }
  121.    function setText(t)
  122.    {
  123.       if(this.initializing)
  124.       {
  125.          this.initText = t;
  126.       }
  127.       else
  128.       {
  129.          var _loc2_ = this.label;
  130.          if(_loc2_.html == true)
  131.          {
  132.             _loc2_.htmlText = t;
  133.          }
  134.          else
  135.          {
  136.             _loc2_.text = t;
  137.          }
  138.       }
  139.       this.dispatchValueChangedEvent(t);
  140.    }
  141.    function size(Void)
  142.    {
  143.       this.border_mc.setSize(this.__get__width(),this.__get__height());
  144.       var _loc2_ = this.border_mc.__get__borderMetrics();
  145.       var _loc6_ = _loc2_.left + _loc2_.right;
  146.       var _loc3_ = _loc2_.top + _loc2_.bottom;
  147.       var _loc5_ = _loc2_.left;
  148.       var _loc4_ = _loc2_.top;
  149.       this.tfx = _loc5_;
  150.       this.tfy = _loc4_;
  151.       this.tfw = this.__get__width() - _loc6_;
  152.       this.tfh = this.__get__height() - _loc3_;
  153.       this.label.move(this.tfx,this.tfy);
  154.       this.label.setSize(this.tfw,this.tfh + 1);
  155.    }
  156.    function setEnabled(enable)
  157.    {
  158.       this.label.type = !(this.__editable == true || enable == false) ? "dynamic" : "input";
  159.       this.label.selectable = enable;
  160.       var _loc2_ = this.getStyle(!enable ? "disabledColor" : "color");
  161.       if(_loc2_ == undefined)
  162.       {
  163.          _loc2_ = !enable ? 8947848 : 0;
  164.       }
  165.       this.setColor(_loc2_);
  166.    }
  167.    function setColor(col)
  168.    {
  169.       this.label.textColor = col;
  170.    }
  171.    function onKillFocus(newFocus)
  172.    {
  173.       if(this.enterListener != undefined)
  174.       {
  175.          Key.removeListener(this.enterListener);
  176.       }
  177.       if(this.bind != undefined)
  178.       {
  179.          this.updateModel(this.__get__text());
  180.       }
  181.       super.onKillFocus(newFocus);
  182.    }
  183.    function onSetFocus(oldFocus)
  184.    {
  185.       var f = Selection.getFocus();
  186.       var o = eval(f);
  187.       if(o != this.label)
  188.       {
  189.          Selection.setFocus(this.label);
  190.          return undefined;
  191.       }
  192.       if(this.enterListener != undefined)
  193.       {
  194.          Key.addListener(this.enterListener);
  195.       }
  196.       super.onSetFocus(oldFocus);
  197.    }
  198.    function draw(Void)
  199.    {
  200.       var _loc2_ = this.label;
  201.       var _loc4_ = this.getText();
  202.       if(this.initializing)
  203.       {
  204.          this.initializing = false;
  205.          delete this.initText;
  206.       }
  207.       var _loc3_ = this._getTextFormat();
  208.       _loc2_.embedFonts = _loc3_.embedFonts == true;
  209.       if(_loc3_ != undefined)
  210.       {
  211.          _loc2_.setTextFormat(_loc3_);
  212.          _loc2_.setNewTextFormat(_loc3_);
  213.       }
  214.       _loc2_.multiline = false;
  215.       _loc2_.wordWrap = false;
  216.       if(_loc2_.html == true)
  217.       {
  218.          _loc2_.setTextFormat(_loc3_);
  219.          _loc2_.htmlText = _loc4_;
  220.       }
  221.       else
  222.       {
  223.          _loc2_.text = _loc4_;
  224.       }
  225.       _loc2_.type = !(this.__editable == true || this.enabled == false) ? "dynamic" : "input";
  226.       this.size();
  227.    }
  228.    function setEditable(s)
  229.    {
  230.       this.__editable = s;
  231.       this.label.type = !s ? "dynamic" : "input";
  232.    }
  233.    function get maxChars()
  234.    {
  235.       return this.label.maxChars;
  236.    }
  237.    function set maxChars(w)
  238.    {
  239.       this.label.maxChars = w;
  240.    }
  241.    function get length()
  242.    {
  243.       return this.label.length;
  244.    }
  245.    function get restrict()
  246.    {
  247.       return this.label.restrict;
  248.    }
  249.    function set restrict(w)
  250.    {
  251.       this.label.restrict = w != "" ? w : null;
  252.    }
  253.    function get hPosition()
  254.    {
  255.       return this.label.hscroll;
  256.    }
  257.    function set hPosition(w)
  258.    {
  259.       this.label.hscroll = w;
  260.    }
  261.    function get maxHPosition()
  262.    {
  263.       return this.label.maxhscroll;
  264.    }
  265.    function get editable()
  266.    {
  267.       return this.__editable;
  268.    }
  269.    function set editable(w)
  270.    {
  271.       this.setEditable(w);
  272.    }
  273.    function get password()
  274.    {
  275.       return this.label.password;
  276.    }
  277.    function set password(w)
  278.    {
  279.       this.label.password = w;
  280.    }
  281.    function get tabIndex()
  282.    {
  283.       return this.label.tabIndex;
  284.    }
  285.    function set tabIndex(w)
  286.    {
  287.       this.label.tabIndex = w;
  288.    }
  289.    function set _accProps(val)
  290.    {
  291.       this.label._accProps = val;
  292.    }
  293.    function get _accProps()
  294.    {
  295.       return this.label._accProps;
  296.    }
  297. }
  298.